package com.bf.action;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import org.apache.struts2.ServletActionContext;
import com.opensymphony.xwork2.ActionSupport;

public class BaseAction extends ActionSupport {
	
	public static final String SUCCESS = "success";
	public static final String ERROR = "error";
	public static final String INDEX = "index";
	public static final String FINDBYPAGE = "findByPage";
	public static final String LIST = "list";
	public static final String SHOWADD = "showAdd";
	public static final String SHOWUPDATE = "showUpdate";
	public static final String TREE = "tree";
	public static final int PAGESIZE = 15;
	private int pageNo = 0;
	
	protected Integer id;
	protected Integer[] ids;

	public String getParameter(String str) {
		return ServletActionContext.getRequest().getParameter(str);
	}

	public void setAttribute(String key, Object value) {
		ServletActionContext.getRequest().setAttribute(key, value);
	}

	public Object getAttribute(String key) {
		return ServletActionContext.getRequest().getAttribute(key);
	}

	public HttpSession getSession() {
		return ServletActionContext.getRequest().getSession();
	}

	public HttpServletResponse getResponse() {
		return ServletActionContext.getResponse();
	}

	public HttpServletRequest getRequest() {
		return ServletActionContext.getRequest();
	}


	public int getPageNo() {
		String str_pageNo = getParameter("pager.offset");
		if(str_pageNo != null) {
			pageNo = Integer.parseInt(str_pageNo);
		}
		return pageNo;
	}

	public void setPageNo(int pageNo) {
		this.pageNo = pageNo;
	}

	public Integer getId() {
		return id;
	}

	public void setId(Integer id) {
		this.id = id;
	}

	public Integer[] getIds() {
		return ids;
	}

	public void setIds(Integer[] ids) {
		this.ids = ids;
	}

}
